package com.library.librarybackend.service;

import com.library.librarybackend.domain.dto.AttachmentUploadDTO;
import com.library.librarybackend.domain.dto.AttachmentUploadsDTO;
import com.library.librarybackend.domain.entity.Attachment;
import com.baomidou.mybatisplus.extension.service.IService;
import com.library.librarybackend.domain.vo.AttachmentVO;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.function.Consumer;

/**
 * @author MR
 * @description 针对表【attachment(附件表)】的数据库操作Service
 * @createDate 2025-09-21 14:28:03
 */
public interface AttachmentService extends IService<Attachment> {

    /**
     * 上传
     *
     * @param attachmentUploadDTO 上传参数
     * @return 附件信息
     * @throws IOException 抛出IO异常
     */
    AttachmentVO upload(AttachmentUploadDTO attachmentUploadDTO) throws IOException;

    /**
     * 批量上传
     *
     * @param build 上传参数
     * @return 附件信息
     */
    List<AttachmentVO> uploads(AttachmentUploadsDTO build);

    /**
     * 下载
     *
     * @param objName  文件名
     * @param consumer 消费输入流
     */
    void download(String objName, Consumer<InputStream> consumer);

    /**
     * 获取输入流
     *
     * @param objName 文件名
     * @return 输入流
     */
    InputStream download(String objName);

    /**
     * 根据objName查询
     * @param objName objName
     * @return 附件信息
     */
    AttachmentVO queryByObjName(String objName);
}
